home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Testing & Debugging / BusErrorTest / BusErrTest.a next >
Encoding:
Text File  |  1993-01-18  |  3.0 KB  |  101 lines  |  [TEXT/MPS ]

  1. ***********************************************************************
  2. ***
  3. ***        BusErrTest
  4. ***        
  5. ***        Build commands:
  6. ***
  7. ***        asm BusErrTest.a
  8. ***        link BusErrTest.a.o -o BusErrTest
  9. ***
  10. ***********************************************************************
  11.  
  12.                     STRING    ASIS
  13.                     PRINT    OFF
  14.                     INCLUDE 'Traps.a'
  15.                     INCLUDE 'QuickEqu.a'
  16.                     INCLUDE 'SysEqu.a'
  17.                     PRINT    ON
  18.                     machine mc68030
  19.  
  20. ***********************************************************************
  21.  
  22. UnImpTrap        EQU        $A89F
  23. HWPriv            EQU        $A198
  24.  
  25. ***********************************************************************
  26. InstallVector    PROC    EXPORT
  27.  
  28.         IMPORT    OldGuy
  29.         IMPORT    BusErrProc
  30.         
  31.         move.l        a0,-(sp)            ;preserve reg
  32.         lea            OldGuy,a0            ;OldGuy is a place to keep the original bus error vector
  33.         move.l        8,(a0)                ;so fill it up with the vector, victor
  34.         lea            BusErrProc,a0        ;get the address of our bus error handler
  35.         move.l        a0,8                ;and install it
  36.         move.l        (sp)+,a0            ;restore reg
  37. outtahere
  38.         rts
  39.         ENDP
  40.         
  41. ***********************************************************************
  42. CauseBusErr        PROC    EXPORT        
  43.         
  44.         movem.l        a0/d0,-(sp)            ;preserve the register we use
  45.         move.l        #$FFFFFFFF,a0        ;this address looks pretty dangerous...
  46.         move.b        (a0),d0
  47.         movem.l        (sp)+,a0/d0            ;restore the registers we use
  48.         rts                                ;it's Miller time
  49.         ENDP
  50.         
  51. ***********************************************************************
  52. ReplaceVector    PROC    EXPORT
  53.         IMPORT    OldGuy
  54.  
  55.         move.l        a0,-(sp)            ;preserve reg
  56.         lea            8,a0                ;point to the 680x0 bus error vector
  57.         move.l        OldGuy,(a0)            ;and fill it full of the original
  58.         move.l        (sp)+,a0            ;restore reg
  59.         rts                                ;system handler vector
  60.         ENDP
  61.         
  62. ***********************************************************************
  63. BusErrProc        PROC    EXPORT            ;THIS CODE ASSUMES THE BUS ERROR
  64.                                         ;EXCEPTION STACK FRAME FOR THE 
  65.                                         ;68030!!! (REF MOTOROLA 68030 USER'S
  66.                                         ;MANUAL PAGE 8-25)
  67.         IMPORT    OldGuy
  68. RegOffset    EQU        4*2
  69.  
  70.         movem.l        a1/d0,-(sp)            ;take only pictures, leave only footprints
  71.         move.b        6+RegOffset(sp),d0    ;get the id nibble for the stack frame
  72.  
  73.         andi.b        #$F0,d0                ;don't care 'bout the lower nibble...
  74.         cmpi.b        #$B0,d0                ;make sure it's the one we like
  75.         bne.s        NotOurs                ;if not, pass it on to system handler
  76.         bclr.b        #0,$A+RegOffset(sp)    ;clear DF bit of Special Status Reg
  77.                                         ;so that the instruction will not be re-tried
  78.         move.l        scrnbase,a1            ;let the user know we arrived by inverting
  79.         move.w        #$2ff,d0            ;a hunk o' screen
  80.         
  81. Loop
  82.         eori.l        #$ffffffff,(a1)+    ;we do a long word at a time
  83.         dbra        d0,Loop                ;till d0 goes negative
  84.         
  85.         movem.l        (sp)+,a1/d0            ;clean up after ourselves
  86. ret        rte                                ;and return from the exception
  87. NotOurs
  88.         movem.l        (sp)+,a1/d0            ;restore battered registers
  89.         move.l        OldGuy,-(sp)        ;and pass control onto the system
  90.         rts                                ;bus error handler
  91.         ENDP
  92.         
  93. ***********************************************************************
  94. OldGuy    PROC    EXPORT
  95.         DC.L    0                        ;a long word for storage
  96.         ENDP
  97.         
  98. theEnd    PROC    EXPORT
  99.         ENDP
  100.  
  101.         END